
import type {Id, PageResult} from "@/api/Common.ts";
import httpClient from "@/api/client.ts";
import type {
  CreateRequest, JoinRequest, LeaveRequest,
  OrganizationVO,
  SearchRequest,
  UpdateRequest
} from "@/api/Organization.ts";

export const OrganizationApi = {

  create: async (param: CreateRequest): Promise<number> => {
    const {data} = await httpClient.post('/admin/organization/create', param)
    return data
  },
  update: async (param: UpdateRequest): Promise<boolean> => {
    const {data} = await httpClient.post('/admin/organization/update', param)
    return data
  },

  join: async (param: JoinRequest): Promise<boolean> => {
    const {data} = await httpClient.post(`/admin/organization/join`, param)
    return data
  },

  leave: async (param: LeaveRequest): Promise<boolean> => {
    const {data} = await httpClient.post(`/admin/organization/leave`, param)
    return data
  },

  search: async (param: SearchRequest): Promise<PageResult<OrganizationVO>> => {
    const {data} = await httpClient.post<PageResult<OrganizationVO>>(`/organization/search`, param)
    return data
  },
}
